package com.ccc.scala.base7_collection

import scala.collection.mutable.ArrayBuffer

object Collection02_ArrayBuffer {
  def main(args: Array[String]): Unit = {
    // 集合 - 可变数组
    val buffer = new ArrayBuffer[String]

    // 操作
    buffer.append("cj", "CJ", "Carl", "Johnson")
    buffer.appendAll(Array("C", "CC", "CCC"))
    println(buffer) // ArrayBuffer(cj, CJ, Carl, Johnson, C, CC, CCC)

    buffer.insert(1, "QQ")
    println(buffer) // ArrayBuffer(cj, QQ, CJ, Carl, Johnson, C, CC, CCC)

    // buffer.update(0, "JC")
    buffer(0) = "JC"
    println(buffer) // ArrayBuffer(JC, QQ, CJ, Carl, Johnson, C, CC, CCC)

    buffer.remove(3, 2)
    println(buffer) // ArrayBuffer(JC, QQ, CJ, C, CC, CCC)

    val buffer1 = buffer - "CJ"
    println(buffer1) // ArrayBuffer(JC, QQ, C, CC, CCC)



  }

}
